package cn.virens.common.boot.rabbit.autoconfig;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;
import java.util.function.Consumer;

@Getter
@Setter
@ConfigurationProperties(prefix = "spring.rabbitmq.manager")
public class RabbitManageProperties {
    private List<RabbitManagePropertiesExchange> exchanges;
    private List<RabbitManagePropertiesQueue> queues;
    private List<RabbitManagePropertiesBind> bindings;

    private String exchangeDefault;
    private String exchangeMqtt;

    private Integer prefetchCount;
    private Integer prefetchSize;

    private Boolean enabled;

    public void exchangeInit(Consumer<RabbitManagePropertiesExchange> consumer) {
        if (exchanges != null && consumer != null) {
            this.exchanges.forEach(consumer);
        }
    }

    public void queueInit(Consumer<RabbitManagePropertiesQueue> consumer) {
        if (queues != null && consumer != null) {
            this.queues.forEach(consumer);
        }
    }

    public void bindInit(Consumer<RabbitManagePropertiesBind> consumer) {
        if (bindings != null && consumer != null) {
            this.bindings.forEach(consumer);
        }
    }
}
